$OpenBSD: patch-ede-panel_applets_cpu-monitor_CpuMonitor_cpp,v 1.3 2014/09/17 07:47:38 espie Exp $
--- ede-panel/applets/cpu-monitor/CpuMonitor.cpp.orig	Sat Jun 21 15:24:21 2014
+++ ede-panel/applets/cpu-monitor/CpuMonitor.cpp	Wed Sep 17 01:46:03 2014
@@ -36,20 +36,24 @@
 # include <string.h> /* strncmp */
 #endif
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 # include <sys/param.h>
 # include <sys/sysctl.h>
+#if defined(__OpenBSD__)
+#include <sys/sched.h>
+#else
 # if __FreeBSD_version < 500101
 #  include <sys/dkstat.h>
 # else
 #  include <sys/resource.h>
 # endif
+#endif
 # include <sys/stat.h>
 #endif
 
 #include "CpuMonitor.h"
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 
 /* The part ripped from top... */
 /*
@@ -481,15 +485,18 @@ void CPUMonitor::get_cpu_info() {
 
 #endif /* have_kstat_h */
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 	size_t len = sizeof(cp_time);
+	int mib[2];
 
 	cpu[samples()-1][IWM_USER] = 0;
 	cpu[samples()-1][IWM_NICE] = 0;
 	cpu[samples()-1][IWM_SYS] = 0;
 	cpu[samples()-1][IWM_IDLE] = 0;
 
-	if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) == -1)
+	mib[0] = CTL_KERN;
+	mib[1] = KERN_CPTIME;
+	if (sysctl(mib, 2, &cp_time, &len, NULL, 0) == -1)
 		return; /* FIXME : need err handler? */
 
 	percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff);
